﻿// ******************************************************
// SMS.Framework
// SMS.Framework.Mathematic
// Geometry.cs
// Copyright (c) 2009, SMS Framework. All Rights Reserved.
// ******************************************************

using System;

namespace SMS.Framework.Mathematic
{

    public class Geometry
    {

        /// <summary> 
        /// Calculates the area of a circle 
        /// </summary> 
        /// <param name="radius">Value of the radius of the circle.</param> 
        /// <returns>The value returned is the area of the circle.</returns> 
        /// <remarks></remarks> 
        public double CircleArea(double radius)
        {
            return Math.PI * (Math.Pow(radius, 2));
        }

        /// <summary> 
        /// Calculates the perimeter of a circle 
        /// </summary> 
        /// <param name="radius">Value of the radius of the circle.</param> 
        /// <returns>The value returned is the perimeter of the circle.</returns> 
        /// <remarks></remarks> 
        public double CirclePerimeter(double radius)
        {
            return 2 * Math.PI * radius;
        }

        /// <summary> 
        /// Calculates the area of the portion of a circle 
        /// </summary> 
        /// <param name="radius">Value of the radius of the circle.</param> 
        /// <param name="grades">Value of the grades of the portion of the circle.</param> 
        /// <returns>The value returned is the area of the portion of the circle.</returns> 
        /// <remarks></remarks> 
        public double CirclePortionArea(double radius, double grades)
        {
            return Math.PI * (Math.Pow(radius, 2)) * grades / 360;
        }

        /// <summary> 
        /// Calculates the area of a circular crown 
        /// </summary> 
        /// <param name="totalRadius">Value of the concentric radius plus external or crown radius.</param> 
        /// <param name="concentricRadius">Value of the concentric radius.</param> 
        /// <returns>The value returned is the area of the circular crown.</returns> 
        /// <remarks></remarks> 
        public double CircularCrownArea(double totalRadius, double concentricRadius)
        {
            return Math.PI * (Math.Pow(totalRadius, 2) - Math.Pow(concentricRadius, 2));
        }

        /// <summary> 
        /// Calculates the lateral area of a cone 
        /// </summary> 
        /// <param name="radius">Value of the radius of the cone.</param> 
        /// <param name="height">Value of the height of the cone.</param> 
        /// <returns>The value returned is the lateral area of the cone.</returns> 
        /// <remarks></remarks> 
        public double ConeLateralArea(double radius, double height)
        {
            return Math.PI * radius * Math.Sqrt(Math.Pow(radius, 2) + Math.Pow(height, 2));
        }

        /// <summary> 
        /// Calculates the volume of a cone 
        /// </summary> 
        /// <param name="radius">Value of the radius of the cone.</param> 
        /// <param name="height">Value of the height of the cone.</param> 
        /// <returns>The value returned is the volume of the cone.</returns> 
        /// <remarks></remarks> 
        public double ConeVolume(double radius, double height)
        {
            return ((Math.Pow(radius, 2)) * height * Math.PI) / 3;
        }

        /// <summary> 
        /// Calculates the area of a cube 
        /// </summary> 
        /// <param name="side">Value of a side. Each side has the same length.</param> 
        /// <returns>The value returned is the area of the cube.</returns> 
        /// <remarks></remarks> 
        public double CubeArea(double side)
        {
            return 6 * (Math.Pow(side, 2));
        }

        /// <summary> 
        /// Calculates the volume of a cube 
        /// </summary> 
        /// <param name="side">Value of a side. Each side has the same length.</param> 
        /// <returns>The value returned is the volume of the cube.</returns> 
        /// <remarks></remarks> 
        public double CubeVolume(double side)
        {
            return Math.Pow(side, 3);
        }

        /// <summary> 
        /// Calculates the area of a cylinder 
        /// </summary> 
        /// <param name="radius">Value of the radius of the cylinder.</param> 
        /// <param name="height">Height of the cylinder.</param> 
        /// <returns>The value returned is the area of the cylinder.</returns> 
        /// <remarks></remarks> 
        public double CylinderArea(double radius, double height)
        {
            return 2 * Math.PI * radius * (radius + height);
        }

        /// <summary> 
        /// Calculates the volume of the cylinder 
        /// </summary> 
        /// <param name="radius">Value of the radius of the cylinder.</param> 
        /// <param name="height">Height of the cylinder.</param> 
        /// <returns>The value returned is the volume of the cylinder.</returns> 
        /// <remarks></remarks> 
        public double CylinderVolume(double radius, double height)
        {
            return Math.PI * (Math.Pow(radius, 2)) * height;
        }

        /// <summary> 
        /// Calculates the area of the ellipse 
        /// </summary> 
        /// <param name="radiusLarge">Value of the large radius of the ellipse.</param> 
        /// <param name="radiusShort">Value of the short radius of the ellipse.</param> 
        /// <returns>The value returned is the area of the ellipse.</returns> 
        /// <remarks></remarks> 
        public double EllipseArea(double radiusLarge, double radiusShort)
        {
            return Math.PI * radiusLarge * radiusShort;
        }

        /// <summary> 
        /// Calculates the area of the hexagon 
        /// </summary> 
        /// <param name="base">Value of the base of the hexagon.</param> 
        /// <param name="apothem">Value of the apothem of the hexagon.</param> 
        /// <returns>The value returned is the area of the hexagon.</returns> 
        /// <remarks></remarks> 
        public double HexagonArea(double @base, double apothem)
        {
            return 3 * @base * apothem;
        }

        /// <summary> 
        /// Calculates the perimeter of the hexagon 
        /// </summary> 
        /// <param name="base">Value of the base of the hexagon.</param> 
        /// <returns>The value returned is the perimeter of the hexagon.</returns> 
        /// <remarks></remarks> 
        public double HexagonPerimeter(double @base)
        {
            return 6 * @base;
        }

        /// <summary> 
        /// Calculates the area of a parallelogram 
        /// </summary> 
        /// <param name="base">Value of the base of the parallelogram.</param> 
        /// <param name="height">Height of the parallelogram.</param> 
        /// <returns>The value returned is the area of the parallelogram.</returns> 
        /// <remarks></remarks> 
        public double ParallelogramArea(double @base, double height)
        {
            return @base * height;
        }

        /// <summary> 
        /// Calculates the perimeter of a parallelogram 
        /// </summary> 
        /// <param name="sideLarge">Side large of the parallelogram.</param> 
        /// <param name="sideShort">Side short of the parallelogram.</param> 
        /// <returns>The value returned is the perimeter of a parallelogram.</returns> 
        /// <remarks></remarks> 
        public double ParallelogramPerimeter(double sideLarge, double sideShort)
        {
            return (sideLarge + sideShort) * 2;
        }

        /// <summary> 
        /// Calculates the area of the pentagon 
        /// </summary> 
        /// <param name="base">Value of the base of the pentagon.</param> 
        /// <param name="apothem">Value of the apothem of the pentagon.</param> 
        /// <returns>The value returned is the area of the pentagon.</returns> 
        /// <remarks></remarks> 
        public double PentagonArea(double @base, double apothem)
        {
            return (5 / 2) * @base * apothem;
        }

        /// <summary> 
        /// Calculates the perimeter of the pentagon 
        /// </summary> 
        /// <param name="base">Value of the base of the pentagon.</param> 
        /// <returns>The value returned is the perimeter of the pentagon.</returns> 
        /// <remarks></remarks> 
        public double PentagonPerimeter(double @base)
        {
            return 5 * @base;
        }

        /// <summary> 
        /// Calculates the volume of a pyramid with rectangular base 
        /// </summary> 
        /// <param name="largeBase">Large of the base of the pyramid.</param> 
        /// <param name="wideBase">Wide of the base of the pyramid.</param> 
        /// <returns>The value returned is the volume of the pyramid with rectangular base.</returns> 
        /// <remarks></remarks> 
        public double PyramidVolume(double largeBase, double wideBase)
        {
            return (largeBase * wideBase) / 3;
        }

        /// <summary> 
        /// Calculates the area of a rectangle 
        /// </summary> 
        /// <param name="base">Base of the rectangle.</param> 
        /// <param name="height">Height of the rectangle.</param> 
        /// <returns>The value returned is the area of the rectangle.</returns> 
        /// <remarks></remarks> 
        public double RectangleArea(double @base, double height)
        {
            return @base * height;
        }

        /// <summary> 
        /// Calculates the perimeter of a rectangle 
        /// </summary> 
        /// <param name="sideLarge">Side large of the rectangle.</param> 
        /// <param name="sideShort">Side short of the rectangle.</param> 
        /// <returns>The value returned is the perimeter of a rectangle.</returns> 
        /// <remarks></remarks> 
        public double RectanglePerimeter(double sideLarge, double sideShort)
        {
            return (sideLarge + sideShort) * 2;
        }

        /// <summary> 
        /// Calculates the volume of a rectangular prism 
        /// </summary> 
        /// <param name="large">Value of the base of the rectangular prism.</param> 
        /// <param name="wide">Value of the wide of the rectangular prism.</param> 
        /// <param name="height">Value of the height of the rectangular prism.</param> 
        /// <returns>The value returned is the volume of the rectangular prism.</returns> 
        /// <remarks></remarks> 
        public double RectagularPrismVolume(double large, double wide, double height)
        {
            return large * wide * height;
        }

        /// <summary> 
        /// Calculates the area of a regular polygon 
        /// </summary> 
        /// <param name="perimeter">Value of the perimeter of the regular polygon.</param> 
        /// <param name="apothem">Value of the apothem of the regular polygon.</param> 
        /// <returns>The value returned is the area of the polygon.</returns> 
        /// <remarks></remarks> 
        public double RegularPolygonArea(double perimeter, double apothem)
        {
            return (perimeter * apothem) / 2;
        }

        /// <summary> 
        /// Calculates the area of a regular polygon 
        /// </summary> 
        /// <param name="firstBase">Value of the first base of the regular polygon.</param> 
        /// <param name="secondBase">Value of the second base of the regular polygon.</param> 
        /// <param name="thirdBase">Value of the third base of the regular polygon.</param> 
        /// <param name="fourthBase">Value of the fourth base of the regular polygon.</param> 
        /// <returns>The value returned is the perimeter of the polygon.</returns> 
        /// <remarks></remarks> 
        public double RegularPolygonPerimeter(double firstBase, double secondBase, double thirdBase, double fourthBase)
        {
            return (firstBase + secondBase + thirdBase + fourthBase);
        }

        /// <summary> 
        /// Calculates the area of a rhomboid 
        /// </summary> 
        /// <param name="base">Base of the rhomboid.</param> 
        /// <param name="height">Height of the rhomboid.</param> 
        /// <returns>The value returned is the area of the rhomboid.</returns> 
        /// <remarks></remarks> 
        public double RhomboidArea(double @base, double height)
        {
            return @base * height;
        }

        /// <summary> 
        /// Calculates the perimeter of a rhomboid 
        /// </summary> 
        /// <param name="base">Base of the rhomboid.</param> 
        /// <returns>The value returned is the perimeter of the rhomboid.</returns> 
        /// <remarks></remarks> 
        public double RhomboidPerimeter(double @base)
        {
            return @base * 4;
        }

        /// <summary> 
        /// Calculates the area of a rhombus 
        /// </summary> 
        /// <param name="horizontalDiagonal">Value of one of the diagonals of the rhombus.</param> 
        /// <param name="verticalDiagonal">The second value of the other diagonal of the rhombus.</param> 
        /// <returns>The value returned is the area of the rhombus.</returns> 
        /// <remarks></remarks> 
        public double RhombusArea(double horizontalDiagonal, double verticalDiagonal)
        {
            return (horizontalDiagonal * verticalDiagonal) / 2;
        }

        /// <summary> 
        /// Calculates the perimeter of a rhombus 
        /// </summary> 
        /// <param name="firstBase">Value of the first base of the rhombus.</param> 
        /// <param name="secondBase">Value of the second base of the rhombus.</param> 
        /// <param name="thirdBase">Value of the third base of the rhombus.</param> 
        /// <param name="fourthBase">Value of the fourth base of the rhombus.</param> 
        /// <returns>The value returned is the perimeter of the rhombus.</returns> 
        /// <remarks></remarks> 
        public double RhombusPerimeter(double firstBase, double secondBase, double thirdBase, double fourthBase)
        {
            return (firstBase + secondBase + thirdBase + fourthBase);
        }

        /// <summary> 
        /// Calculates the area of an sphere 
        /// </summary> 
        /// <param name="radius">Radio of the sphere.</param> 
        /// <returns>The value returned is the area of a sphere.</returns> 
        /// <remarks></remarks> 
        public double SphereArea(double radius)
        {
            return (Math.Pow(radius, 2)) * Math.PI * 4;
        }

        /// <summary> 
        /// Calculates the volume of an sphere 
        /// </summary> 
        /// <param name="radius">Radio of the sphere.</param> 
        /// <returns>The value returned is the area of a sphere.</returns> 
        /// <remarks></remarks> 
        public double SphereVolume(double radius)
        {
            return (Math.Pow(radius, 3)) * (Math.PI * 4 / 3);
        }

        /// <summary> 
        /// Calculates the area of an square 
        /// </summary> 
        /// <param name="base">Base of the square.</param> 
        /// <returns>The value returned is the area of a square.</returns> 
        /// <remarks></remarks> 
        public double SquareArea(double @base)
        {
            return Math.Pow(@base, 2);
        }

        /// <summary> 
        /// Calculates the perimeter of an square 
        /// </summary> 
        /// <param name="side">Side of the square.</param> 
        /// <returns>The value returned is the perimeter of an square.</returns> 
        /// <remarks></remarks> 
        public double SquarePerimeter(double side)
        {
            return side * 4;
        }

        /// <summary> 
        /// Calculates the area of a trapeze 
        /// </summary> 
        /// <param name="lowerBase">Value of the lower base of the trapeze.</param> 
        /// <param name="upperBase">Value of the upper base of the trapeze.</param> 
        /// <param name="height">Height of the trapeze.</param> 
        /// <returns>The value returned is the area of the trapeze.</returns> 
        /// <remarks></remarks> 
        public double TrapezeArea(double lowerBase, double upperBase, double height)
        {
            //Return (lowerBase + upperBase) * height / 2 
            return ((lowerBase + upperBase) / 2) * height;
        }

        /// <summary> 
        /// Calculates the area of a triangle 
        /// </summary> 
        /// <param name="base">Base of the triangle.</param> 
        /// <param name="height">Height of the triangle.</param> 
        /// <returns>The value returned is the area of the triangle.</returns> 
        /// <remarks></remarks> 
        public double TriangleArea(double @base, double height)
        {
            return (@base * height) / 2;
        }

        /// <summary> 
        /// Calculates the perimeter of a triangle 
        /// </summary> 
        /// <param name="firstBase">First base of the triangle.</param> 
        /// <param name="secondBase">Second base of the triangle.</param> 
        /// <param name="thirdBase">Third base of the triangle.</param> 
        /// <returns>The value returned is the perimeter of the triangle.</returns> 
        /// <remarks></remarks> 
        public double TrianglePerimeter(double firstBase, double secondBase, double thirdBase)
        {
            return (firstBase + secondBase + thirdBase);
        }

        /// <summary> 
        /// Calculates the volume of a triangular prism 
        /// </summary> 
        /// <param name="large">Large of the triangular prism.</param> 
        /// <param name="wide">Wide of the triangular prism.</param> 
        /// <param name="height">Height of the triangular prism.</param> 
        /// <returns>The value returned is the volume of the triangular prism.</returns> 
        /// <remarks></remarks> 
        public double TriangularPrismVolume(double large, double wide, double height)
        {
            return (large * wide * height) / 2;
        } 

    } // Geometry

} // SMS.Framework.Mathematic